﻿using MediatR;
using RBAC.LuFang.API.Application.Command.MenuCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;

namespace RBAC.LuFang.API.Application.CommandHandlers.MenuHandler
{
    //修改菜单
    public class MenuUpdateCommandHandler:IRequestHandler<MenuUpdateCommand, int>
    {
        private readonly IMenuService _menuService;

        public MenuUpdateCommandHandler(IMenuService menuService)
        {
            _menuService = menuService;
        }

        public async Task<int> Handle(MenuUpdateCommand request, CancellationToken cancellationToken)
        {
            var menuModel = new MenuInfo() { menuInfoId = request.menuInfoId, menuInfoName = request.menuInfoName, menuInfoUrl = request.menuInfoUrl, Pid = request.Pid, addName = request.addName, addDate = request.addDate };
            return await _menuService.UpdMenu(menuModel);
        }
    }
}
